import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/app`

export function getAppnodeList(params) {
  return request.get(`${AUTH_PREFIX_V1}/appnodes`, { params }).then(res => camelCaseObject(res))
}

export function getAppnodeListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/appnodes/page`, { params }).then(res => camelCaseObject(res))
}

export function getAppnode(appnodeId) {
  return request.get(`${AUTH_PREFIX_V1}/appnodes/${appnodeId}`).then(res => camelCaseObject(res))
}

export function createAppnode(params) {
  return request.post(`${AUTH_PREFIX_V1}/appnodes`, params).then(res => camelCaseObject(res))
}

export function updateAppnode(appnodeId, params) {
  return request.put(`${AUTH_PREFIX_V1}/appnodes/${appnodeId}`, params).then(res => camelCaseObject(res))
}

export function deleteAppnode(appnodeId) {
  return request.delete(`${AUTH_PREFIX_V1}/appnodes/${appnodeId}`).then(res => camelCaseObject(res))
}
